﻿using LitJson;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class GamePanel : MonoBehaviour
{
    public Transform row1;
    public Transform row2;
    
    void Start()
    {
        foreach (JsonData item in DataManager.GetInstance().cardList)
        {
            GameObject prefab = ResourceManager.dictionary_prefab[("Assets/Prefab/card.prefab").ToLower()];
            GameObject go = GameObject.Instantiate(prefab, prefab.transform.position, Quaternion.identity);
            go.transform.parent = row1;

            Card card = go.GetComponent<Card>();
            
            card.cardType = (CardType)(int)item["type"];
            card.value = item["value"];
            card.score = (int)item["score"];

            card.Refresh();
        }
        
        //Refresh();
    }

    public void Refresh()
    {
        GameObject prefab = ResourceManager.dictionary_prefab[("Assets/Prefab/card.prefab").ToLower()];
        GameObject go = GameObject.Instantiate(prefab, prefab.transform.position, Quaternion.identity);
        go.transform.parent = row1;
    }
}